<template>
  <Modal v-model="modal" title="提醒" @on-ok="handleConfirm" @on-cancel="handleCancel">
    <p class="waring">批量替换,包括本节点及以下节点,替换之后不可恢复,是否确认替换</p>
  </Modal>
</template>
<script>
import apiObj from '@/api/project-partition.js';

export default {
  props: {
    newStr: String,
    nodeId: Number,
    oldStr: String
  },
  data () {
    return {
      modal: false
    };
  },
  methods: {
    show () {
      this.modal = true;
    },
    hidden () {
      this.modal = false;
    },
    handleConfirm () {
      this.replaceTree();
    },
    handleCancel () {
    },
    async replaceTree () {
      const data = {
        'newStr': this.newStr,
        'nodeId': this.nodeId,
        'oldStr': this.oldStr
      };
      try {
        const resp = await apiObj.replaceTreeNode(data);
        this.$Message.success(`替换成功`);
        this.$emit('on-refresh');
      } catch (error) {
        this.$Message.info(`替换失败`);
      }
    }
  }
};
</script>
<style lang="less" scoped>
.waring{
    text-align: center;
    font-size: 14px;
    color: red;
}
</style>
